import requests
import time

class Nettime():
    def __init__(self):
        pass

    def echo_time(self,stamp):
        stamp = str(stamp)
        # print(stamp[:10],time.time())
        #print(time.ctime(int(stamp[:10])))
        return stamp[:10]

    def req(self,url):
        r = requests.get(url)
        return r

    def beijing(self):
        # 北京时间戳API
        timestamp = self.req("https://time.is/t/?zh.0.347.2464.0p.480.43d.1574683214663.1594044507830.").text[:14]
        return self.echo_time(timestamp)

    def taobao(self):
        # 淘宝时间戳API
        timestamp = self.req("http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp").json()['data']['t']
        return self.echo_time(timestamp)

    def pdd(self):
        # 拼多多时间戳API
        timestamp = self.req("http://api.pinduoduo.com/api/server/_stm").json()['server_time']
        return self.echo_time(timestamp)

    def huawei(self):
        # 华为商城时间戳API
        timestamp = self.req("https://mbuy.vmall.com/getSkuRushbuyInfo.json").json()['currentTime']
        return self.echo_time(timestamp)
